<!DOCTYPE html>

<html>

	<head>
		<meta charset="utf-8">
		<title>菜单管理</title>
		<meta name="renderer" content="webkit">
		<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
		<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
		<link rel="stylesheet" href="<?= RESOURCES ?>/layuiadmin/layuiadmin/layui/css/layui.css" media="all">
		<link rel="stylesheet" href="<?= RESOURCES ?>/layuiadmin/layuiadmin/style/admin.css" media="all">
	</head>

	<body layadmin-themealias="default">

		<div class="layui-fluid">
			<div class="layui-card">
				<div class="layui-card-body" style="padding: 15px;">
					<form class="layui-form" action="" lay-filter="component-form-group">
						<input name="id" hidden="hidden" value="<?=$menu_detail['id']?>" />
						<div class="layui-form-item">
							<div class="layui-inline">
								<label class="layui-form-label">上级菜单</label>
								<div class="layui-input-inline">
									
									<select id="classid" name="classid" lay-verify="required" lay-search="">
										<option value="0" <?php if($menu_detail['classid']==0){?>  selected="selected"  <?php } ?> >顶级菜单</option>
										<?=$html_option?>
									</select>
									
								</div>
							</div>
						</div>

						<div class="layui-form-item">
							<label class="layui-form-label">菜单名称</label>
							<div class="layui-input-block">
								<input value="<?=$menu_detail['u1'] ?>" type="text" name="u1" lay-verify="required" placeholder="菜单名称" autocomplete="off" class="layui-input">
							</div>
						</div>

						<div class="layui-form-item">
							<label class="layui-form-label">菜单地址</label>
							<div class="layui-input-block">
								<input value="<?=$menu_detail['u3'] ?>" type="text" name="u3"   placeholder="菜单地址" autocomplete="off" class="layui-input">
							</div>
						</div>
						
						<div class="layui-form-item">
							<label class="layui-form-label">控制器名称</label>
							<div class="layui-input-block">
								<input value="<?=$menu_detail['u5'] ?>" type="text" name="u5"   placeholder="控制器名称" autocomplete="off" class="layui-input">
							</div>
						</div>
						
						<div class="layui-form-item">
							<label class="layui-form-label">控制器方法</label>
							<div class="layui-input-block">
								<input value="<?=$menu_detail['u6'] ?>" type="text" name="u6"   placeholder="控制器名称" autocomplete="off" class="layui-input">
							</div>
						</div>

						<div class="layui-form-item">
								<label class="layui-form-label">菜单图标</label>
								<div class="layui-input-block">
									<input value="<?=$menu_detail['icon'] ?>" type="text" name="icon"   placeholder="如：&#xe67c; 或 icon-edit" autocomplete="off" class="layui-input" value='layui-icon layui-icon-set'>
								</div>
						</div>
						
						<div class="layui-form-item">
								<label class="layui-form-label">排序</label>
								<div class="layui-input-inline">
									<input value="<?=$menu_detail['u2'] ?>" type="text" name="u2" lay-verify="required" placeholder="请输入整数" autocomplete="off" class="layui-input"  >
								</div>
								<div class="layui-form-mid layui-word-aux">请填写整数（数字越小越靠前）</div>
						</div>

						<div class="layui-form-item">
							<label class="layui-form-label">显示</label>
							<div class="layui-input-block">
								<?php if($menu_detail['u4']=="显示" ){ ?>
									<input type="checkbox" checked="" name="u4" lay-skin="switch" lay-filter="component-form-switchTest" lay-text="显示|隐藏">
									<div class="layui-unselect layui-form-switch layui-form-onswitch" lay-skin="_switch"><em>显示</em><i></i></div>
							
								<?php }else{ ?>
									 <input type="checkbox" name="u4" lay-skin="switch" lay-text="显示|隐藏">
									 <div class="layui-unselect layui-form-switch" lay-skin="_switch"><em>隐藏</em><i></i></div>
									
								<?php } ?>
								</div>
						</div>

						<div class="layui-form-item layui-layout-admin">
							<div class="layui-input-block">
								<div class="layui-footer" style="left: 0;">
									<button class="layui-btn" lay-submit="" lay-filter="component-form-demo1">提交</button>
								</div>
							</div>
						</div>
					</form>
				</div>
			</div>
		</div>

		<script src="<?= RESOURCES ?>/layuiadmin/layuiadmin/layui/layui.js"></script>
		<script>
			layui.config({
				base: '<?= RESOURCES ?>/layuiadmin/layuiadmin/' //静态资源所在路径
			}).extend({
				index: 'lib/index' //主入口模块
			}).use(['index', 'form', 'laydate'], function() {
				var $ = layui.$,
					admin = layui.admin,
					element = layui.element,
					layer = layui.layer,
					laydate = layui.laydate,
					form = layui.form,
					index = parent.layer.getFrameIndex(window.name); //获取窗口索引;

				form.render(null, 'component-form-group');

				laydate.render({
					elem: '#LAY-component-form-group-date'
				});
				

				/* 自定义验证规则 */
				form.verify({
					title: function(value) {
						if(value.length < 5) {
							return '标题至少得5个字符啊';
						}
					},
					pass: [/(.+){6,12}$/, '密码必须6到12位'],
					content: function(value) {
						layedit.sync(editIndex);
					}
				});

				/* 监听提交 */
				form.on('submit(component-form-demo1)', function(data) {
					//请求接口
					admin.req({
						url: '/<?= ADMIN_NAME ?>/menu/update' //实际使用请改成服务端真实接口
							,
						data: data.field,
						done: function(res) {

							//登入成功的提示与跳转
							layer.msg(res.msg, {
								offset: '15px',
								icon: 1,
								time: 1000
							}, function() {
								parent.location.reload(); 
								parent.layer.close(index);
								
							});

						}
					});

					return false;
				});
			});
			
		</script>

		<style id="LAY_layadmin_theme">
			.layui-side-menu,
			.layadmin-pagetabs .layui-tab-title li:after,
			.layadmin-pagetabs .layui-tab-title li.layui-this:after,
			.layui-layer-admin .layui-layer-title,
			.layadmin-side-shrink .layui-side-menu .layui-nav>.layui-nav-item>.layui-nav-child {
				background-color: #20222A !important;
			}
			
			.layui-nav-tree .layui-this,
			.layui-nav-tree .layui-this>a,
			.layui-nav-tree .layui-nav-child dd.layui-this,
			.layui-nav-tree .layui-nav-child dd.layui-this a {
				background-color: #009688 !important;
			}
			
			.layui-layout-admin .layui-logo {
				background-color: #20222A !important;
			}
		</style>
	</body>

</html>